<?php

/*
 * This file is part of the Geek-Zoo Projects.
 *
 * @copyright (c) 2010 Geek-Zoo Projects More info http://www.geek-zoo.com
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License
 * @author quqiang <quqiang@geek-zoo.com>
 *
 */
require ROOT_PATH.'/Helper/front_abstract.php';

class Action extends front_abstract
{
   public function index() //为POST添加方法　
    {
		if(Request::isPost()){
			$content = strip_tags(_POST('content'));
			if(empty($content)){
			
				$this->msg('不能为空!');
			}
			
			
				if(!filter_content($content)){
				
		
					$onepost['user_id'] = $this->info['id'];//获取用户ID
		
					$onepost['add_time'] = time();//添加时间

					$onepost['content']=$content;

					// if($onepost['user_id'] == ""){
					// 
					// 	if(strlen($onepost['content']) > 60){
					// 
					// 		$this->msg('超过20个字,注册后可以解除发言字数限制');
					// 		exit;
					// 	}	
					// }

					if(strlen($onepost['content']) < 30){
					
						$this->msg('连10个字都没有？看来你的嘴还不够闲呢。');
					}

		            		_model("post")->create($onepost);//
		
		            		$this->redirect('index');
				}else{

					$this->msg("这内容太太...太危险了，所以不能发");
		
				}

		}
    }
   public function check($post_Key,$post)//教研函数
    {
	
        $newpost=array();

        foreach($post as $check_Key=>$check_val){
	
				$check_val=strip_tags($check_val);//去HTMLi标签去空格
				
				$newcheck_val=trim($check_val);
				
			if(in_array($check_Key, $post_Key) && !empty($newcheck_val)){//兼职过滤，教研非空
			
				$newpost[$check_Key]=$newcheck_val;
				
			}
	
		}

        return $newpost;

    

    }
    public function uncheck($check_unset, $post)
    {
        if(is_array($check_unset)){
	
            foreach($check_unset as $val){
	
                unset($post[$val]);

            	}

         }else{
	
                unset($post[$check_unset]);
            }

        return $post;
    }
}
?>
